package com.yunshan.mp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yunshan.common.annotation.Log;
import com.yunshan.common.core.controller.BaseController;
import com.yunshan.common.core.domain.AjaxResult;
import com.yunshan.common.enums.BusinessType;
import com.yunshan.mp.domain.MpIndexBanner;
import com.yunshan.mp.service.IMpIndexBannerService;
import com.yunshan.common.utils.poi.ExcelUtil;
import com.yunshan.common.core.page.TableDataInfo;

/**
 * 首页banner配置Controller
 * 
 * @author yunshan
 * @date 2025-01-20
 */
@Api(tags = "首页banner配置")
@RestController
@RequestMapping("/mp/banner")
public class MpIndexBannerController extends BaseController
{
    @Autowired
    private IMpIndexBannerService mpIndexBannerService;

    /**
     * 查询首页banner配置列表
     */
    @ApiOperation("查询首页banner配置列表")
    @GetMapping("/list")
    public TableDataInfo list(MpIndexBanner mpIndexBanner)
    {
        startPage();
        List<MpIndexBanner> list = mpIndexBannerService.selectMpIndexBannerList(mpIndexBanner);
        return getDataTable(list);
    }

    /**
     * 导出首页banner配置列表
     */
    @ApiOperation("导出首页banner配置列表")
    @Log(title = "首页banner配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MpIndexBanner mpIndexBanner)
    {
        List<MpIndexBanner> list = mpIndexBannerService.selectMpIndexBannerList(mpIndexBanner);
        ExcelUtil<MpIndexBanner> util = new ExcelUtil<MpIndexBanner>(MpIndexBanner.class);
        util.exportExcel(response, list, "首页banner配置数据");
    }

    /**
     * 获取首页banner配置详细信息
     */
    @ApiOperation("获取首页banner配置详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mpIndexBannerService.selectMpIndexBannerById(id));
    }

    /**
     * 新增首页banner配置
     */
    @ApiOperation("新增首页banner配置")
    @Log(title = "首页banner配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MpIndexBanner mpIndexBanner)
    {
        return toAjax(mpIndexBannerService.insertMpIndexBanner(mpIndexBanner));
    }

    /**
     * 修改首页banner配置
     */
    @ApiOperation("修改首页banner配置")
    @Log(title = "首页banner配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MpIndexBanner mpIndexBanner)
    {
        return toAjax(mpIndexBannerService.updateMpIndexBanner(mpIndexBanner));
    }

    /**
     * 删除首页banner配置
     */
    @ApiOperation("删除首页banner配置")
    @Log(title = "首页banner配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mpIndexBannerService.deleteMpIndexBannerByIds(ids));
    }
}
